package cn.iocoder.yudao.module.lowcode.controller.admin.datasource.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Schema(description = "管理后台 - 数据源连接测试 Response VO")
@Data
public class DatasourceConnectionTestRespVO {

    @Schema(description = "测试结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
    private Boolean success;

    @Schema(description = "响应时间(毫秒)", example = "123")
    private Long responseTime;

    @Schema(description = "测试消息", example = "连接成功")
    private String message;

    @Schema(description = "错误详情")
    private String errorDetails;

    public static DatasourceConnectionTestRespVO success(Long responseTime, String message) {
        DatasourceConnectionTestRespVO resp = new DatasourceConnectionTestRespVO();
        resp.success = true;
        resp.responseTime = responseTime;
        resp.message = message;
        return resp;
    }

    public static DatasourceConnectionTestRespVO failure(String message, String errorDetails) {
        DatasourceConnectionTestRespVO resp = new DatasourceConnectionTestRespVO();
        resp.success = false;
        resp.message = message;
        resp.errorDetails = errorDetails;
        return resp;
    }
}